<?php
	session_start();
	require_once '../data/Banque.php';
	$code_secret_expected = ConfigClement::$code_secret;
	$separator = ConfigClement::$separator_address;
	
	$nom = $_POST['name'];
	$adress = $_POST['adresse1'].$separator.$_POST['adresse2'].$separator.$_POST['adresse3'].$separator.$_POST['adresse4'];
	$phone = $_POST['phone'];
	$mail = $_POST['email'];
	$login = $_POST['username'];
	$password = $_POST['thepwddiv'];
	$code_secret = $_POST['code_secret'];
	
 	if($code_secret == $code_secret_expected){
 		$banque = new Banque($nom, $adress, $phone, $mail, $login, $password);
 		$banque->saveBanque();
 		$_SESSION['banque'] = serialize(Banque::getBanqueByLoginAndPassword($login, $password));
 		
 		header("Location:../genericmessage.php?type=success&message=Votre inscription a bien été enregistrée.");
 	} else {
 		header("Location:../inscription.php?register_error");
 	}
?>